<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title>大猿图书管理系统</title>
</head>

<body style="text-align: center; margin-top: 50px">
<div>
    <form action="/book" method="get">
        书名：<input type="text" name="bookName" value="${bookName}"><br><br>
        作者：<input type="text" name="author" value="${author}"><br><br>
        <input type="hidden" name="action" value="queryByName">
        <input type="text" name="currentPage" value="1">
        <button>查询</button>
    </form>

</div>

<div>
    <table>
        <tr>
            <td>ID</td>
            <td>书名</td>
            <td>作者</td>
            <td>价格</td>
            <td>出版社</td>
        </tr>

        <c:forEach items="${bookInfos}" var="book">
            <tr>
                <td>${book.id}</td>
                <td>${book.bookName}</td>
                <td>${book.author}</td>
                <td>${book.price}</td>
                <td>${book.publisherName}</td>
            </tr>
        </c:forEach>

    </table>
</div>

<div>
    <a href="">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="###" onclick="pre()">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="###" onclick="next()">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="">尾页</a>
</div>
</body>

<footer></footer>

    <script>
        //当前页
        var currentPage = ${currentPage};
        var totalPage = ${totalPage};

        function next() {
            if (currentPage == totalPage) {
                return;
            }
            currentPage ++;
            window.location.href = '/book?action=queryByName&currentPage=' + currentPage;
        }

        function pre() {
            if (currentPage == 1) {
                return;
            }
            currentPage --;
            window.location.href = '/book?action=queryByName&currentPage=' + currentPage;
        }


    </script>

</html>